#!/usr/bin/env python
#coding=utf-8

import sys

(last_key, max_val) = (None, -sys.maxint)
for line in sys.stdin:
    # print line
    # print line.strip().split(",")
    try:
        (key, val) = line.strip().split(",")
        if last_key and last_key!= key:
            print "%s,%s"%(last_key,max_val)
            (last_key, max_val) = (key, int(val))
        else:
            (last_key, max_val) = (key, max(max_val, int(val)))
    except:
        print "==================error=========================="
        continue
if last_key:
    print "%s,%s"%(last_key, max_val)